import { BasicColumn, FormSchema } from '/@/components/Table';
import { render } from '/@/utils/common/renderUtils';
import { DescItem } from '/@/components/Description/index';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n('');

export const columns: BasicColumn[] = [
  {
    title: t('表单名称'),
    dataIndex: 'name',
    width: 100,
  },
  {
    title: t('表单标识'),
    dataIndex: 'code',
    width: 100,
  },
  {
    title: t('提交次数'),
    dataIndex: 'submitCount',
    width: 100,
  },
  {
    title: t('提交类型'),
    dataIndex: 'submitType',
    width: 100,
  },
  {
    title: t('状态'),
    dataIndex: 'status',
    width: 100,
    customRender: ({text}) => {
      let color = 'green'
      if (text === '0') {
        color = 'red'
      }
      return render.renderTag(render.renderDict(text, 'data_use_status'), color)
    },
  },
  {
    title: t('创建时间'),
    dataIndex: 'updatedAt',
    width: 150,
    align: 'center',
  }
];

export const searchFormSchema: FormSchema[] = [
  {
    label: t('状态'),
    field: 'status',
    component: 'Input',
  },
  {
    label: t('表单名称'),
    field: 'name',
    component: 'Input',
  },
];



export const inputFormSchemas: FormSchema[] = [
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
  {
    label: t('表单标识'),
    field: 'code',
    component: 'Input',
    componentProps: {
      maxlength: 200,
    },

  },
  {
    label: t('提交次数'),
    field: 'submitCount',
    component: 'Input',
    componentProps: {
      maxlength: 0,
    },

  },
  {
    label: t('提交类型'),
    field: 'submitType',
    component: 'Input',
    componentProps: {
      maxlength: 2,
    },

  },
  {
    label: t('状态'),
    field: 'status',
    component: 'Input',
    componentProps: {
      maxlength: 2,
    },

  },
  {
    label: t('表单名称'),
    field: 'name',
    component: 'Input',
    componentProps: {
      maxlength: 300,
    },

  },
  {
    label: t('表单项'),
    field: 'items',
    component: 'Input',
    componentProps: {
      maxlength: 0,
    },

  },
  {
    label: t('备注'),
    field: 'remark',
    component: 'InputTextArea',
    componentProps: {
      maxlength: 500,
    },
    colProps: { lg: 24, md: 24 },
  },
];


export const formDetailSchema: DescItem[] = [
  {
    label: t('表单标识'),
    field: 'code'
  },
  {
    label: t('提交次数'),
    field: 'submitCount'
  },
  {
    label: t('提交类型'),
    field: 'submitType'
  },
  {
    label: t('状态'),
    field: 'status'
  },
  {
    label: t('表单名称'),
    field: 'name'
  },
  {
    label: t('备注'),
    labelMinWidth: 40,
    field: 'remark',
  },
];
